package com.wkq.util.transformer

import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 *
 *@Author: wkq
 *
 *@Time: 2025/7/28 18:01
 *
 *@Desc: 仿 iOS CoverFlow 效果
 */
class CoverFlowTransformer : ViewPager2.PageTransformer {
    override fun transformPage(view: View, position: Float) {
        val scale = 1 - Math.abs(position) * 0.2f
        view.scaleX = scale
        view.scaleY = scale
        view.rotationY = position * -30
        view.alpha = if (Math.abs(position) <= 0.5) 1f else 0.5f
        view.translationX = -position * view.width * 0.3f
    }
}
